package com.papers.common.enums;

import lombok.Getter;

/**
 * 题型枚举
 *
 * @author libo
 * @date 2022/10/21 10:24
 */
@Getter
public enum QuestionType {

    /**
     * 单选题
     */
    SINGLE_OPTION("1", "单选题"),

    /**
     * 多选题
     */
    MULTI_OPTION("2", "多选题"),

    /**
     * 填空题
     */
    FILL("3", "填空题"),

    /**
     * 判断题
     */
    JUDGMENT("4", "判断题"),

    /**
     * 解答题
     */
    ANSWER("5", "解答题");

    private String key;

    private String value;

    QuestionType(String key, String value) {
        this.key = key;
        this.value = value;
    }

    /**
     * 获得key对应的枚举
     *
     * @param key key值
     * @return 枚举
     */
    public static QuestionType getEnumByKey(String key) {
        for (QuestionType qt : QuestionType.values()) {
            if (qt.getKey().equals(key)) {
                return qt;
            }
        }
        return null;
    }

}
